#ifndef DEVICE_H
#define DEVICE_H

#include <string>
#include <map>

using namespace std;
class Device {
public:
    enum class DeviceType { DEFAULT, LIGHT, THERMOSTAT, CAMERA, SOCKET };

    // 定义虚函数
    virtual void turnOn() = 0;
    virtual void turnOff() = 0;

    //Device() : id(0), type(DeviceType::DEFAULT) {} // 默认构造函数
    Device(int id, DeviceType type);

    int getId() const;
    DeviceType getType() const;
    const std::string& getStatus() const;
    void setStatus(const std::string& newStatus);

private:
    int id;
    DeviceType type;
    std::string status;
};

// 灯具类
class Light : public Device {
public:
    Light(int id);
    void turnOn() override;
    void turnOff() override;
    void setBrightness(int brightness);

private:
    int brightness;
};


// 温控器类
class Thermostat : public Device {
public:
    Thermostat(int id);
    void turnOn() override;
    void turnOff() override;
    void setTemperature(double temperature);
    double getCurrentTemperature() const;

private:
    double currentTemperature;
    double targetTemperature;
};

// 摄像头类
class Camera : public Device {
public:
    Camera(int id);
    void turnOn() override;
    void turnOff() override;
    void setResolution(const std::string& resolution);

private:
    std::string resolution;
};

// 插座类
class Socket : public Device {
public:
    Socket(int id);
    void turnOn() override;
    void turnOff() override;
};

// 设备工厂类
class DeviceFactory {
public:
    static Device* createDevice(Device::DeviceType type, int id);
};

#endif
